/*
 * Brown, Gregory; Negron, Luz; Noecker, David; Spangler, Michael
 * Pennsylvania State University
 * 2011
 *
 * Copyright (c) 2011, Brown Negron Noecker Spangler
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * - Neither the name of Pennsylvania State University nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Student class for IST 411 project
 * This class provides the basic structure for a student.
 */

package courseScheduler;

import java.sql.SQLException;

/**
 *
 * @author Greg Brown
 */
public class Student extends Person{

    /**
     * Student constructor that takes in name and D.O.B.
     *
     * @param newFName value for the first name.
     * @param newLName value for the last name.
     * @param newDOB value for the date of birth.
     */
    Student(String newFName, String newLName, date newDOB){
        super(newFName, newLName, newDOB);
    }

    /**
     * Constructor for Student that uses an existing person.
     * @param newPerson existing person.
     */
    Student(Person newPerson){
        super(newPerson);
    }

    //Attributes
    int idNumber;

    //Gets and Sets
    //<editor-fold>
    /**
     * Class method for setting Student ID
     * @param newID value for the new student ID
     */
    void setID(int newID){
        idNumber = newID;
    }

    /**
     * Class method for accessing the Student ID
     * @return Student ID
     */
    int getID(){
        return idNumber;
    }
    //</editor-fold>

    public static String[] getPrefixes(java.sql.Connection conn, int id) throws java.sql.SQLException{
        String [] prefixes;
        java.sql.ResultSet rs = conn.createStatement().executeQuery
                (
                    "SELECT type_ FROM student_section JOIN section on student_section.section_id = section.id"
                    + "JOIN course ON section.course_id = course.id WHERE student_section.id = " + id +";"
                );
        if (rs.first()){
            int count = 0;
            rs.last();
            prefixes = new String[rs.getRow()];
            rs.beforeFirst();
            while(rs.next()){
                boolean isThere = false;
                String temp = rs.getString(1);
                for(int i = 0; i < prefixes.length; i ++){
                    if (temp.equals(prefixes[i])){
                        isThere = true;
                    }
                }
                    prefixes[count] = rs.getString(1);
                    count ++;
            }
        }
        else {
            prefixes = new String [1];
            prefixes [0] = "";
        }
        return prefixes;
    }

    /*public static int[] getNumbers(java.sql.Connection conn,int id){
        int Numbers [];

        return Numbers;
    }*/
    
}
